Skip to content

Conversation

@michaeltlombardi
Copy link
Collaborator

PR Summary

This change follows the Rust "parse, don't validate pattern" by defining a TypeVersion enum with the Semantic and String variants. If the version can be parsed as a semantic version, the type creates it as an instance of TypeVersion::Semantic and otherwise creates it as TypeVersion::String.

The TypeVersion enum implements several conversion and comparison traits to make using the newtype more ergonomic. It also defines helper methods is_semver() and matches_semver_req() for easier usage.

When comparing an instance of TypeVersion:

  • A semantic version is always greater than an arbitrary string version. This applies both when comparing TypeVersion::String instances to TypeVersion::Semantic and to semver::Version.
  • Arbitrary string version comparisons are case-insensitive. Foo and foo are equal but Foo is greater than Bar.
  • You can directly compare instances of TypeVersion to string slices, String instances, and semver::Version instances in addition to other instances of TypeVersion.
  • The trait implementations support using ==, >, and < operators for easier reading.

The newtype overhauls the JSON Schema for versions to help users get better validation and IntelliSense when authoring manifests.

Finally, this change adds comprehensive integration tests for the newtype and its implementations as well as documentation for the type and its public methods.

PR Context

Prior to this change, the version fields for DSC used an arbitrary String for both resources and extensions. The generated schema for those types then reports that any string is valid and DSC must check every time it needs to process the version for whether the version is semantic or an arbitrary string.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@michaeltlombardi michaeltlombardi force-pushed the gh-538/main/type_version branch from 790b3d3 to f151f75 Compare January 13, 2026 16:44
Prior to this change, the version fields for DSC used an arbitrary
`String` for both resources and extensions. The generated schema for
those types then reports that any string is valid and DSC must check
every time it needs to process the version for whether the version is
semantic or an arbitrary string.

This change follows the Rust "parse, don't validate pattern" by defining
a `TypeVersion` enum with the `Semantic` and `String` variants. If the
version can be parsed as a semantic version, the type creates it as
an instance of `TypeVersion::Semantic` and otherwise creates it as
`TypeVersion::String`.

The `TypeVersion` enum implements several conversion and comparison
traits to make using the newtype more ergonomic. It also defines helper
methods `is_semver()` and `matches_semver_req()` for easier usage.

When comparing an instance of `TypeVersion`:

- A semantic version is always greater than an arbitrary string version.
  This applies both when comparing `TypeVersion::String` instances to
  `TypeVersion::Semantic` and to `semver::Version`.
- Arbitrary string version comparisons are case-insensitive. `Foo` and
  `foo` are equal but `Foo` is greater than `Bar`.
- You can directly compare instances of `TypeVersion` to string slices,
  `String` instances, and `semver::Version` instances in addition to
  other instances of `TypeVersion`.
- The trait implementations support using `==`, `>`, and `<` operators
  for easier reading.

The newtype overhauls the JSON Schema for versions to help users get
better validation and IntelliSense when authoring manifests.

Finally, this change adds comprehensive integration tests for the
newtype and its implementations as well as documentation for the type
and its public methods.
Prior to this change, the shared type definitions for `TypeVersion`
and `FullyQualifiedTypeName` were accessed throughout the code as
`dsc_lib::types::<TypeName>`.

This change converts the `types` module to private and re-exports
the types from the crate root, making them accessible as
`dsc_lib::<TypeName>` instead, which is more ergonomic and maps
better to describing basic reusable types for DSC that aren't
specific to a particular module.
Prior to this change, the `version` fields for `ResourceManifest` and
`DscResource` were defined as the `String` type. This change updates
those fields to use `TypeVersion` to more correctly support
distinguishing between semantic versions and arbitrary string versions.

This change also adds the `semantic_version()` method to `DscResource`
to return an `Option` containing a reference to the semantic version
if possible. This enables retrieving the semantic version more easily
instead of re-parsing the version string as a semantic version.

This change updates references to the `version` field across the code
base as needed.
@michaeltlombardi michaeltlombardi force-pushed the gh-538/main/type_version branch from 170bfe1 to 5955b07 Compare January 13, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant